//
//  PigHeaderView.m
//  PigMarket
//
//  Created by mac on 2019/4/10.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "PigHeaderView.h"
#import "PigVarietyView.h"
#import "PigBasicInformationView.h"
#import "PigTrusteePriceView.h"
#import "HeaderScroll.h"



@interface PigHeaderView ()
/**
 轮播图
 */
@property (nonatomic , strong) HeaderScroll *videoScrollView;

/**
 猪品种和个性签名
 */
@property (nonatomic , strong) PigVarietyView *varietyView;
/**
 仔猪信息
 */
@property (nonatomic , strong) PigBasicInformationView *infoView;
/**
 食谱
 */
@property (nonatomic , strong) UIButton *foodBookBtn;
/**
 喂养
 */
@property (nonatomic , strong) UIButton *eatBtn;
/**
 食谱喂养背景
 */
@property (nonatomic , strong) UIView *eatBgView;
/**
 竖灰线
 */
@property (nonatomic , strong) UIView *sLine;
@property (nonatomic, strong) NSMutableArray    *list;
@end
@implementation PigHeaderView

#pragma mark - init method
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    
    [self addSubview:self.videoScrollView];
    [self addSubview:self.varietyView];
    [self addSubview:self.eatBgView];
    [self.eatBgView addSubview:self.foodBookBtn];
    [self.eatBgView addSubview:self.sLine];
    [self.eatBgView addSubview:self.eatBtn];
    [self addSubview:self.infoView];
}

- (void)initLayout {
    // 布局子控件
    [self.videoScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(ScaleHeight(240));
    }];
    [self.varietyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.videoScrollView.mas_bottom).offset(0);
    }];
    [self.eatBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.varietyView.mas_bottom).offset(10);
        make.left.right.mas_equalTo(0);
    }];
    
    [self.foodBookBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX).multipliedBy(0.5);
        make.top.mas_equalTo(18);
        make.bottom.mas_equalTo(-18);
    }];
    [self.sLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.foodBookBtn.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(2, 26));
    }];
    [self.eatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX).multipliedBy(1.5);
        make.top.mas_equalTo(18);
        make.bottom.mas_equalTo(-18);
    }];
    [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.eatBgView.mas_bottom).offset(10);
        make.left.right.mas_equalTo(0);
    }];
}

#pragma mark - getter and setter
- (void)setHeaderDataArr:(NSMutableArray *)headerDataArr {
    NSMutableArray *imgUrlArr = [[NSMutableArray alloc] init];
    for (AdoptDetail *model in headerDataArr) {
        [imgUrlArr addObject:model.materialName];
    }
//    [self.videoScrollView setImageBlock:^(HeaderScrollModel *model) {
//        NSLog(@"图片id = %ld",model.pigImgId);
//    }];
//    [self.videoScrollView setAVPlayerBlock:^(HeaderScrollModel *model) {
//        NSLog(@"视频id = %ld",model.pigImgId);
//    }];

}
- (void)setDataModel:(AdoptDetailList *)dataModel {
    self.varietyView.pigTitle.text = dataModel.varietiesName;
    self.varietyView.numLab.text = [NSString stringWithFormat:@"编号:%@",dataModel.pigNum];
    self.varietyView.personalRemarkLab.text = dataModel.personality;
    self.infoView.weightDetailLab.text = [NSString stringWithFormat:@"%.2fkg(%@)",dataModel.weight,dataModel.weighDate];
    self.infoView.priceDetailLab.text = dataModel.unitPrice;
    self.infoView.birthdayDetailLab.text = dataModel.birthDate;
    self.infoView.currentDaysDetailLab.text = [NSString stringWithFormat:@"%@天",dataModel.age];
    self.infoView.dateDetailLab.text = [NSString stringWithFormat:@"%@(饲养周期%@天)",dataModel.expectOutDate,dataModel.cycle];
    self.infoView.breedGroundDetailLab.text = dataModel.pigField;
    
    [self.videoScrollView setScrollModleList:dataModel.maters];
}
- (PigVarietyView *)varietyView {
    if (!_varietyView) {
        _varietyView = [[PigVarietyView alloc] init];
        _varietyView.backgroundColor = [UIColor whiteColor];
    }
    return _varietyView;
}
- (PigBasicInformationView *)infoView {
    if (!_infoView) {
        _infoView = [[PigBasicInformationView alloc] init];
        _infoView.backgroundColor = [UIColor whiteColor];
    }
    return _infoView;
}

- (HeaderScroll *)videoScrollView {
    if (!_videoScrollView) {
        _videoScrollView = [[HeaderScroll alloc] init];
    }
    return _videoScrollView;
}

- (UIView *)eatBgView {
    if (!_eatBgView) {
        _eatBgView = [[UIView alloc] init];
        _eatBgView.backgroundColor = [UIColor whiteColor];
    }
    return _eatBgView;
}

- (UIView *)sLine {
    if (!_sLine) {
        _sLine = [[UIView alloc] init];
        _sLine.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
    }
    return _sLine;
}
- (UIButton *)foodBookBtn {
    if (!_foodBookBtn) {
        _foodBookBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_foodBookBtn setTitle:@"它的食谱" forState:UIControlStateNormal];
        [_foodBookBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        _foodBookBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_foodBookBtn setImage:[UIImage imageNamed:@"adopt_adoptdetail_foodbook"] forState:UIControlStateNormal];
        [_foodBookBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 10)];
    }
    return _foodBookBtn;
}
- (UIButton *)eatBtn {
    if (!_eatBtn) {
        _eatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_eatBtn setTitle:@"清饲喂养" forState:UIControlStateNormal];
        [_eatBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        _eatBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_eatBtn setImage:[UIImage imageNamed:@"adopt_adoptdetail_eat"] forState:UIControlStateNormal];
        [_eatBtn setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 10)];
        
    }
    return _eatBtn;
}
@end
